home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tprint.zip / REPPRN.PAS < prev    next >
Pascal/Delphi Source File  |  1991-05-10  |  3KB  |  133 lines

  1. Unit RepPrn;
  2. Interface
  3. Uses Printer,WinTypes,wObjects,winDos;
  4. Type
  5.   hStr = array[0..79] of Char;
  6.  
  7.   pReportPrinter = ^tReportPrinter;
  8.   tReportPrinter = object(tPrinter)
  9.     Heading1: hStr;
  10.     Heading2: hStr;
  11.     lineCount: Integer;
  12.     maxLines: Integer;
  13.     pageCount: Integer;
  14.     rDateTime: hStr;
  15.  
  16.     Function setRunTime: Boolean;
  17.     Function setPageNum: Boolean;
  18.     Function setHeading2: Boolean;
  19.     Function printMainHeadings: Boolean;
  20.     Function setDefaults(hText: string): Boolean;
  21.     Function printHeadings: Boolean;
  22.     Function startNewPage: Boolean;
  23.     Function outText(tLine: pChar): Boolean;
  24.     Constructor Init(inst: tHandle;
  25.                      par: pWindowsObject;
  26.                      ml: Integer);
  27.   End;
  28.  
  29. Implementation
  30. Uses Strings;
  31.  
  32. CONSTRUCTOR tReportPrinter.Init;
  33. Begin
  34.   tPrinter.Init(inst,par);
  35.   lineCount := 99;
  36.   pageCount := 0;
  37.   maxLines := ml;
  38.   FillChar(heading1, SizeOF(heading1),#32);
  39.   FillChar(heading2, SizeOF(heading2),#32);
  40.   SetRunTime;
  41. End;
  42.  
  43. Function tReportPrinter.setDefaults(hText: string): Boolean;
  44. Begin
  45.   strPCopy(heading1,hText);
  46.   setHeading2;
  47. End;
  48.  
  49. Function tReportPrinter.setHeading2: Boolean;
  50. Begin
  51.   strMove(Heading2,rDateTime,strLen(rDateTime));
  52.   strMove(@heading2[68],'PAGE',4);
  53.   setPageNum;
  54. End;
  55.  
  56. Function tReportPrinter.SetPageNum: Boolean;
  57. var
  58.   pCount: array[0..3] of Char;
  59.  
  60. Begin
  61.   str(pageCount,pCount);
  62.   strCopy(@heading2[73],pCount);
  63. End;
  64.  
  65. Function tReportPrinter.printMainHeadings: Boolean;
  66. Begin
  67.   setPageNum;
  68.   printLine(heading1);
  69.   printLine(heading2);
  70. End;
  71.  
  72. Function tReportPrinter.printHeadings: Boolean;
  73. Begin
  74.   newLine;
  75.   inc(pageCount);
  76.   printMainHeadings;
  77.   newLine;
  78.   newLine;
  79.   lineCount := 5;
  80. End;
  81.  
  82. Function tReportPrinter.StartNewPage: Boolean;
  83. Begin
  84.   if (pageCount > 0) then begin
  85.     newPage;
  86.     printHeadings;
  87.   End;
  88. End;
  89.  
  90. Function tReportPrinter.outText(tLine: pChar): Boolean;
  91. Begin
  92.   if (lineCount > maxLines) then
  93.     startNewPage;
  94.   printLine(tLine);
  95.   inc(lineCount);
  96. End;
  97.  
  98. Function tReportPrinter.SetRunTime: Boolean;
  99. var
  100.   m,d,y,dw: Word;
  101.   temp,tag: string[4];
  102.   tStr: String;
  103.  
  104. Begin
  105.   tStr := '';
  106.   GetTime(y,m,d,dw);
  107.   if (y > 12) then begin
  108.     y := (y - 12);
  109.     tag := 'pm';
  110.   End else
  111.     tag := 'am';
  112.   str(y,temp);
  113.   if (y < 10) then
  114.     temp := '0' + Temp;
  115.   tStr := tStr + temp + ':';
  116.   str(m,Temp);
  117.   tStr := tStr + temp + ':';
  118.   str(d,temp);
  119.   tStr := tStr + temp + tag + '     ';
  120.   GetDate(y,m,d,dw);
  121.   str(m,Temp);
  122.   if (m < 10) then
  123.     temp := '0' + temp;
  124.   tStr := tStr + temp + '/';
  125.   str(d,Temp);
  126.   if (d < 10) then
  127.     Temp := '0' + temp;
  128.   tStr := tStr + Temp + '/';
  129.   str(y,temp);
  130.   tStr := tStr + temp;
  131.   strPcopy(rDateTime,tStr);
  132. End;
  133. End.